<!--
 * @FilePath     : /study_code/layui/13-2-37.html
 * @Description  : 自定义 table 列模板
 * @Date         : 2025-04-07 17:14:26
 * @Author       : Fang YingGui
 * @LastEditors  : fangyinggui 18715384437@163.com
 * @LastEditTime : 2025-04-08 13:35:26
-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>documentName</title>
    <link rel="stylesheet" href="/layui/dist/css/layui.css" />
  </head>
  <body>
    <table id="demo" lay-filter="test"></table>

    <script src="/layui/dist/layui.js"></script>
    <script src="/layui/table/common.js"></script>
    <script>
      var table = layui.table,
        form = layui.form

      table.render({
        elem: '#demo',
        data: tableData,

        cols: [
          [
            {
              field: 'id',
              title: 'ID',
              minWidth: 400,
            },
            // 很多列-start
            { field: 'sex', title: '性别', width: 160 },
            { field: 'city', title: '城市', width: 160 },
            {
              field: 'sign',
              title: '签名',
              width: 240,
              /**
               * @brief:自定义列模板
               * 共 3 种方式，常用下面这种
               * 【详细】见 laytpl 模板语法
               * @return {*}
               */
              templet: function (d) {
                var html = ''
                html +=
                  '<div class="layui-form">' +
                  '<input type="text" class="layui-input" placeholder="请输入积分" value="' +
                  d.sign +
                  '" />' +
                  '</div>'
                return html
              },
            },
            { field: 'experience', title: '积分', width: 160 },
            { field: 'score', title: '评分', width: 160 },
            { field: 'classify', title: '职业', width: 160 },
            // 很多列-end
            {
              //
              field: 'wealth',
              title: '财富',
              width: 160,
              fixed: 'right',
            },
          ],
        ],

        done: function () {
          form.render()
        },
      })
    </script>
  </body>
</html>